package com.tc.netty;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

/**
 * @Auther: tianchao
 * @Date: 2022/2/11 11:08
 * @Description:
 */
@Slf4j
public class TestJdkFuture {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService service = Executors.newFixedThreadPool(2);
        final Future<Integer> future = service.submit((Callable<Integer>) () -> {
            log.debug("执行计算");
            Thread.sleep(1000);
            return 50;
        });
        log.debug("等待结果");
        log.debug("结果是 {}", future.get());
    }
}
